<?php 
require_once("includes/config.php"); 
  if(isset($_POST['add-periods']) && $_POST['add-periods'] == 1)
  {
    $result = query("UPDATE periods SET period_from = ?, period_to = ? where period_id=?",$_POST['from-1'],$_POST['to-1'],1);
    $result = query("UPDATE periods SET period_from = ?, period_to = ? where period_id=?",$_POST['from-2'],$_POST['to-2'],2);
    $result = query("UPDATE periods SET period_from = ?, period_to = ? where period_id=?",$_POST['from-3'],$_POST['to-3'],3);
     
    $_SESSION['success_message'] = "تم تحديث فترات الايجار";
  }
  if(isset($_POST['value']))
  {
    $sql = "UPDATE apartments SET " .$_POST['field']." = ? Where id=?";
    $result = query($sql,$_POST['value'],$_POST['id']);
    echo $_POST['value'];
    die();
  }
  
  render("settings.php", array("title"=>"الإعدادات"));

?>